from concurrent import futures
import grpc

import hello_pb2
import hello_pb2_grpc


class Greeter(hello_pb2_grpc.GreeterServicer):
    def SayHello(self, request, context):
        return hello_pb2.HelloReply(message=f"Hello, {request.name}")



def server():
    port = "50051"
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    hello_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) 
    server.add_insecure_port(f"[::]:{port}")
    server.start()
    print(f"Server started listening on {port}")
    server.wait_for_termination()


server()
    



